VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} FProjects 
   Caption         =   "Select a Project to Document"
   ClientHeight    =   3195
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3510
   OleObjectBlob   =   "FProjects.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "FProjects"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''' VBA Code Documentor 5.0 by Rob Bovey, copyright 1996-2004,
''' all rights reserved. May be redistributed for free,
''' but may not be sold without the author's explicit permission.
Option Explicit

''' **************************************************************************
''' UserForm Constant Declarations Follow
''' **************************************************************************
Private Const mszMODULE As String = "FProjects"
Private Const mszCAPTION As String = "Select a Project to Document"


''' **************************************************************************
''' UserForm Variable Declarations Follow
''' **************************************************************************
Private mbUserCancel As Boolean
Private mbEnableEvents As Boolean
Private mwkbTarget As Excel.Workbook


''' **************************************************************************
''' UserForm Property Procedures Follow
''' **************************************************************************
Public Property Get UserCancel() As Boolean
    UserCancel = mbUserCancel
End Property

Public Property Get Book() As Excel.Workbook
    Set Book = mwkbTarget
End Property


''' **************************************************************************
''' UserForm Event Procedures Follow
''' **************************************************************************
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    ''' Route all non-code close requests through the Cancel button click event procedure.
    If CloseMode <> vbFormCode Then
        Cancel = True
        cmdCancel_Click
    End If
End Sub


Private Sub cmdOK_Click()
    mbUserCancel = False
    Me.Hide
End Sub


Private Sub cmdCancel_Click()
    mbUserCancel = True
    Me.Hide
End Sub


Private Sub lstProjects_Click()
    If mbEnableEvents Then
        If lstProjects.ListIndex > -1 Then
            Set mwkbTarget = Application.Workbooks(lstProjects.Text)
            cmdOK.Enabled = True
        End If
    End If
End Sub


''' **************************************************************************
''' UserForm Method Procedures Follow
''' **************************************************************************
Public Function Initialize() As Boolean
    mbEnableEvents = False
    Application.Calculate
    Initialize = bLoadBookList()
    Me.Caption = mszCAPTION
    mbEnableEvents = True
End Function


''' **************************************************************************
''' UserForm Private Procedures Follow
''' **************************************************************************
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Comments:   Returns the list of open workbooks from the data sheet.
'''
''' Returns:    Boolean     True if there are workbooks open (besides this one)
'''                         False if no workbooks are open.
'''
''' Date        Developer           Action
''' --------------------------------------------------------------------------
''' 08/27/99    Rob Bovey           Created
'''
Private Function bLoadBookList() As Boolean

    Dim bReturn As Boolean
    Dim rngCell As Excel.Range
    Dim rngBookList As Excel.Range
    Dim wkbBook As Excel.Workbook
    Dim lNumBooks As Long
    Dim szBookName As String
    
    lstProjects.Clear
    bReturn = False
    lNumBooks = wksProgramData.Range(gszRNG_NUM_BOOKS).Value
    
    ''' If only 1 workbook is in the list, it's this one, so we can't continue.
    If lNumBooks > 1 Then
        
        Set rngBookList = wksProgramData.Range(gszRNG_BOOK_LIST_START).Resize(1, lNumBooks)
        
        For Each rngCell In rngBookList
            szBookName = rngCell.Value
            ''' Don't include the name of this workbook in the array
            If StrComp(szBookName, ThisWorkbook.Name, vbTextCompare) <> 0 Then
                Set wkbBook = Application.Workbooks(szBookName)
                ''' Only include workbooks whose projects are unprotected
                If wkbBook.VBProject.Protection = vbext_pp_none Then
                    bReturn = True
                    lstProjects.AddItem szBookName
                End If
            End If
        Next rngCell
        
    End If

    If bReturn Then lstProjects.ListIndex = -1
    
    bLoadBookList = bReturn
    
End Function
